/*=========================================================================

Program:   Virtual Surgery
Language:  C++
Date:      2009-9-1
Version:   0.1
Mail:		   nelfylee@gmail.com

Copyright (c) 2009 Nelfy Lee. All rights reserved.

=========================================================================*/
#ifndef _FILTERING_THREAD_BASE_H_
#define _FILTERING_THREAD_BASE_H_

#include <QThread>
#include <QModelIndex>

#include "itkProcessObject.h"
#include "itkCommand.h"

#include "vtkImageData.h"

#include "Source.h"


class FilteringThreadBase : public QThread
{
	Q_OBJECT

public:
	typedef itk::MemberCommand<FilteringThreadBase>  ProgressCommandType;

	FilteringThreadBase(Source *source)
	{
		m_source = source;
	}

protected:
	virtual void ProcessEvent(itk::Object *caller, const itk::EventObject &event)
	{
		if( typeid(itk::ProgressEvent) == typeid(event))
		{
			::itk::ProcessObject::Pointer process =
				dynamic_cast< itk::ProcessObject *>(caller);

			emit(emitProgressUpdate(process->GetProgress()*100));
		}
	}

	virtual void run() = 0;

signals:
	void emitProgressStart(QString);
	void emitProgressUpdate(int);
	void emitProgressDone();

	// Tell display model
	void emitStartRealTimeSlicing(Source*);
	void emitStopRealTimeSlicing();
	void emitUpdateSlicing(vtkImageData*, int);

protected:
	Source *m_source;
};





#endif


